
import { addTag, getTag } from '@/services';
import { TagList } from '@/utils/poster';
import { Effect, Reducer } from 'umi';
export interface IndexModelState {
    name: string;
    getTag: Array<TagList>,
}
export interface IndexModelType {
    namespace: 'tags';
    state: IndexModelState;
    effects: {
        getTag: Effect;
        // addTag: Effect
    };
    reducers: {
        save: Reducer<IndexModelState>;
    };
}
const IndexModel: IndexModelType = {
    namespace: 'tags',
    state: {
        name: '',
        getTag: [],
    },
    effects: {
        //获取标签
        *getTag({ payload }, { call, put }) {
            let result = yield call(getTag);
            yield put({
                type: 'save',
                payload: {
                    getTag: result.data
                }
            })
        },
        //添加标签
        // *addTag({ payload }, { call, put }) {
        //     let result = yield call(addTag, payload.params);
        //     console.log(payload, 'result')
        //     yield put({
        //         type: 'save',
        //         payload: {

        //         }
        //     })
        // },
    },
    reducers: {
        save(state, action) {
            return {
                ...state,
                ...action.payload,
            };
        },
    },

};

export default IndexModel;